<form nz-form [formGroup]="validateForm">
  <ng-container>
    <nz-form-item>
      <nz-form-label [nzFor]="'pattern'" nzRequired>正则</nz-form-label>
      <nz-form-control [nzErrorTip]="combineTpl">
        <input nz-input id="pattern" formControlName="pattern" placeholder="请输入正则表达式" />
      </nz-form-control>
    </nz-form-item>
    <nz-form-item>
      <nz-form-label [nzFor]="'content'" nzRequired>内容</nz-form-label>
      <nz-form-control [nzErrorTip]="combineTpl">
        <input nz-input id="content" formControlName="content" placeholder="请输入内容" />
      </nz-form-control>
    </nz-form-item>
  </ng-container>
</form>

<!-- 添加按钮 -->
<div style="margin-top: 16px">
  <button nz-button nzType="primary" (click)="validateRegex()">校验</button>
</div>

<!-- 显示校验结果 -->
<div style="margin-top: 16px">
  <nz-alert *ngIf="validationResult !== null" [nzType]="validationResult ? 'success' : 'error'" [nzMessage]="validationResult"></nz-alert>
</div>

<ng-template #combineTpl let-control>
  @if (control.hasError('required')) {
    必填项
  }
</ng-template>
